package com.pinxixi.category.mapper;

import com.pinxixi.framework.domain.category.Category;
import com.pinxixi.framework.domain.specification.Specification;
import com.pinxixi.framework.domain.specification.SpecificationOption;
import com.pinxixi.framework.domain.specification.ext.SpecificationEntity;
import com.pinxixi.framework.domain.specification.ext.SpecificationExt;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface CategoryMapper {

    @Select("select id,parent_id parentId,name,type_id typeId from tb_item_cat where parent_id=#{parentId}")
    List<Category> findListByPid(Long parentId);

    @Insert("insert into tb_item_cat set parent_id=#{parentId},name=#{name},type_id=#{typeId}")
    void add(Category category);

    @Update("update tb_item_cat set parent_id=#{parentId},name=#{name},type_id=#{typeId} where id=#{id}")
    void edit(Category category);

    @Select("select id,parent_id parentId,name,type_id typeId from tb_item_cat where id=#{id}")
    Category findOne(Long id);

    @Delete("delete from tb_item_cat where id=#{id}")
    void delete(Long id);

    @Select("select id,parent_id parentId,name,type_id typeId from tb_item_cat")
    List<Category> findAll();

    @Select("select id,parent_id parentId,name,type_id typeId from tb_item_cat where name=#{name}")
    Category findByName(String name);
}
